package test
import ninenineqs._

/**
  * Created by wyc on 6/11/2017.
  * Find the number of elements of a list.
  * Example:
  * scala> length(List(1, 1, 2, 3, 5, 8))
  * res0: Int = 6
  */

class test_p04 extends UnitSpec{
  feature(this.getClass.toString) {
    val L1 = List(9, 1, 2, 3, 5, 8)
    val L2 = List[Int]()
    val L3 = List(4)

    val Ts:List[(List[Int]) => Int]=List(
      p04.length_v1,
      p04.length_v2,
      p04.length_v3
    )

    var v = 1
    for ( func <- Ts ) {
      scenario("length_v" + v) {
        assert(func(L1) == 6)
        assert(func(L2) == 0)
        assert(func(L3) == 1)
      }
      v += 1
    }
  }
}
